﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DigiLib;
using System.Drawing.Imaging;
using System.Drawing;

public partial class Pages_Captcha : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
        if (!IsPostBack) {
            int width = Convert.ToInt32(Request["width"]);
            int height = Convert.ToInt32(Request["height"]);
            int captch_duration = 6;
            string source = "1234567890";
            string font = "Arial";

            this.Session["CaptchaImageText"] = DigiLib.StringUtils.RamdomString(captch_duration, source);

            CaptchaImage ci = new CaptchaImage(this.Session["CaptchaImageText"].ToString(), width, height, font, Color.LightGray, Color.White, Color.Black, Color.Black);

            this.Response.Clear();
            this.Response.ContentType = "image/jpeg";

            ci.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);

            ci.Dispose();
        }
    }
}